package com.outfoodmanage.controller;

import java.util.List;

import com.outfoodmanage.domain.FoodOrder;
import com.outfoodmanage.service.IFoodOrderService;
import com.rys.common.utils.Search;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单Controller
 *
 * @author ruoyi
 * @date 2025-01-23
 */
@Controller
@RequestMapping("/system/order")
public class FoodOrderController extends BaseController
{
    private String prefix = "system/order";

    @Autowired
    private IFoodOrderService foodOrderService;

    @RequiresPermissions("system:order:view")
    @GetMapping("/{storeId}")
    public String order(@PathVariable("storeId")  String storeId, ModelMap mmap)
    {
        mmap.put("storeId",storeId);
        return prefix + "/order";
    }

    /**
     * 查询订单列表
     */
    @RequiresPermissions("system:order:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FoodOrder foodOrder)
    {
        startPage();
        Search search = new Search();
        search.add("storeId",foodOrder.getStoreId());
        List<FoodOrder> list = foodOrderService.getList(search,"id desc");
        return getDataTable(list);
    }
//
//    /**
//     * 导出订单列表
//     */
//    @RequiresPermissions("system:order:export")
//    @Log(title = "订单", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    @ResponseBody
//    public AjaxResult export(FoodOrder foodOrder)
//    {
//        List<FoodOrder> list = foodOrderService.selectFoodOrderList(foodOrder);
//        ExcelUtil<FoodOrder> util = new ExcelUtil<FoodOrder>(FoodOrder.class);
//        return util.exportExcel(list, "order");
//    }
//
//    /**
//     * 新增订单
//     */
//    @GetMapping("/add")
//    public String add()
//    {
//        return prefix + "/add";
//    }
//
//    /**
//     * 新增保存订单
//     */
//    @RequiresPermissions("system:order:add")
//    @Log(title = "订单", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    @ResponseBody
//    public AjaxResult addSave(FoodOrder foodOrder)
//    {
//        return toAjax(foodOrderService.insertFoodOrder(foodOrder));
//    }
//
//    /**
//     * 修改订单
//     */
//    @GetMapping("/edit/{id}")
//    public String edit(@PathVariable("id") Long id, ModelMap mmap)
//    {
//        FoodOrder foodOrder = foodOrderService.selectFoodOrderById(id);
//        mmap.put("foodOrder", foodOrder);
//        return prefix + "/edit";
//    }
//
//    /**
//     * 修改保存订单
//     */
//    @RequiresPermissions("system:order:edit")
//    @Log(title = "订单", businessType = BusinessType.UPDATE)
//    @PostMapping("/edit")
//    @ResponseBody
//    public AjaxResult editSave(FoodOrder foodOrder)
//    {
//        return toAjax(foodOrderService.updateFoodOrder(foodOrder));
//    }
//
//    /**
//     * 删除订单
//     */
//    @RequiresPermissions("system:order:remove")
//    @Log(title = "订单", businessType = BusinessType.DELETE)
//    @PostMapping( "/remove")
//    @ResponseBody
//    public AjaxResult remove(String ids)
//    {
//        return toAjax(foodOrderService.deleteFoodOrderByIds(ids));
//    }
}